<div class="modal-header">
	<button type="button" class="close" data-dismiss="modal" aria-label="Close">
		<span aria-hidden="true">&times;</span>
	</button>
	<h5 class="modal-title" id="addModalLabel">添加</h5>
</div>

            <form id="addForm" role="form" class="form-horizontal parsley-form" data-parsley-validate
                  action="${base}/platform/allot/addDo" method="post">
                <div class="modal-body">
                <div class="row mb10">
                    <div class="col-lg-12">
                   		<div class="form-group">
                            <label for="company_id" class="col-sm-2 control-label">选择主体</label>
                            <div class="col-sm-8">
                                <select id="company_id" name="company_id" class="form-control" onchange="chooseSchool(this.value)" required="required">
                                	<option value="">--选择主体--</option>
                                	<%for(company in obj.companyList){%>
                                		 <option value="${company.id}">${company.name}</option>
                                	<%}%>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="school_id" class="col-sm-2 control-label">选择驾校</label>
                            <div class="col-sm-8">
                                <select id="school_id" name="school_id" class="form-control" >
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="product_type" class="col-sm-2 control-label">产品类型</label>
                            <div class="col-sm-8">
                                <select id="product_type" name="product_type" class="form-control"  required="required">
                                	<option value="">--选择产品类型--</option>
                                	<%for(product_type in obj.productTypeList){%>
                                		 <option value="${product_type.id}">${product_type.name}</option>
                                	<%}%>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="company_ratio" class="col-sm-2 control-label">主体比例</label>

                            <div class="col-sm-8">
                                <input type="text" id="company_ratio" class="form-control" name="company_ratio" required="required" placeholder="主体比例">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="school_ratio" class="col-sm-2 control-label">驾校比例</label>

                            <div class="col-sm-8">
                                <input type="text" id="school_ratio" class="form-control" name="school_ratio" required="required" placeholder="驾校比例">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="trainer_ratio" class="col-sm-2 control-label">培训者比例</label>

                            <div class="col-sm-8">
                                <input type="text" id="trainer_ratio" class="form-control" name="trainer_ratio" required="required" placeholder="培训者比例">
                            </div>
                        </div>
                    </div>
                </div>
                </div>
	<div class="modal-footer">
		<button  class="btn btn-default btn-sm btn-parsley" >完成</button> 
	</div>
            </form>
<script language="JavaScript">
$(document).ready(function () {
	var dialog=$("#addModal");
	$("#addModalDialog").draggable();
    $('#addForm').ajaxForm({
        dataType: 'json',
        beforeSubmit: function (arr, form, options) {
        },
        success: function (data, statusText, xhr, form) {
            if (data.code==0) {
                Toast.success(data.msg);
                datatable.ajax.reload();
                dialog.modal("hide");
            } else {
            	Toast.error(data.msg);
                datatable.ajax.reload();
                dialog.modal("hide");
            }
        }
    });
}); 
    
  	//驾校选择
    function chooseSchool(value){
    	$.ajax({
			url : "${base}/platform/allot/chooseSchool",
			data : {
				company_id : value
			},
			type : "post",
			async : false,
			dataType : "json",
			success : function(data){
				var html="<option value=''>--选择驾校--</option>";
				for(var i=0;i<data.length;i++){
					html+=' <option value="'+data[i].id+'">'+data[i].name+'</option>';
				}
				$("#school_id").html(html);
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				return false;
			}
		});
    }
</script>
